home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Nejlepší hry
/
Nejlepsi hry.iso
/
hry
/
sea of chaos
/
sea_install.msi
/
_15C39AAA7726369D39812BD40F01CF6A
/
_81883F688FDF4DF484484E7B1770E306
< prev
next >
Wrap
Text File
|
2004-11-27
|
2KB
|
62 lines
///campfire particle shader
//input should be 4 points that are the same position
//color0 (diffuse) used normally
//color1 (spec): green,red are tex coord, blue = size modifier
//Luke Lenhart
//(C)2004-2005 Digipen Institute of Technology
//world,view,projection transform
float4x4 matWorldViewProj;
//camera position in world space
float4 cameraPos;
//particle size modifier
float size;
//base position of emitter
float3 basePos;
//shader input
struct VS_INPUT
{
float4 Pos : POSITION;
float4 Color : COLOR0;
float4 Spec : COLOR1;
};
//shader output
struct VS_OUTPUT
{
float4 Pos : POSITION;
float4 Color : COLOR;
float2 Tex0 : TEXCOORD0;
};
//shader code
VS_OUTPUT VShader(VS_INPUT In)
{
VS_OUTPUT Out;
//transform pos and copy tex coord and color over
Out.Pos=mul(matWorldViewProj,In.Pos);
Out.Tex0=In.Spec.xy;
Out.Color=In.Color;
//expand outwards from center point, based on distance and tex coord
float distmod=0.08f + 1.0f / pow(distance(cameraPos,In.Pos),0.5f);
float2 posOffset=In.Spec.xy - float2(0.5f,0.5f);
float sizeMod=(0.5f + In.Spec.z*2.0f);
//calc rotation matrix based on in component
float theta=dot(In.Pos,float3(0.2f,0.2f,0.2f))+(1.0f / pow(In.Pos.z-basePos.z, 1.5f))*8.0f;
float2x2 matRot={cos(theta),sin(theta),-sin(theta),cos(theta)};
posOffset=mul(matRot,posOffset);
//app offset to output position
Out.Pos.xy+=posOffset*distmod*size*sizeMod;
//spit out the results
return Out;
}